Interfacing the RGB LED with the Arduino

Components
Code Compiler
const int PIN_RED = 12;
const int PIN_GREEN = 9;
const int PIN_BLUE = 6;

//variables to hold our color intensities
int red; int green; int blue;

void setColor(int R, int G, int B) {
analogWrite(PIN_RED, R);
analogWrite(PIN_GREEN, G);
analogWrite(PIN_BLUE, B);
}

void setup() {
//set all three pins to output mode
pinMode(PIN_RED, );
pinMode(PIN_GREEN, );
pinMode(PIN_BLUE, );
}

void loop() {
// set the colors of the LED
setColor(, , );
delay(1000);
setColor(, , );
delay(1000);
setColor(, , );
delay(1000);
}

© 2024 | Virtual Labs, IIT Roorkee